# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=srb2
pkgver=2.2.13
pkgrel=0
pkgdesc="A 3D Sonic fan game based off of Doom Legacy"
url="https://srb2.org"
arch="all !armhf !armv7 !s390x" # arm-hf/v7 and s390x problem with gcc
license="GPL-2.0-only"
depends="srb2-data libgme libopenmpt sdl2_mixer libpng curl"
makedepends="libgme-dev libopenmpt-dev sdl2_mixer-dev libpng-dev curl-dev envsubst"
options="!check" # no test
source="$pkgname-$pkgver.tar.gz::https://github.com/STJr/SRB2/archive/refs/tags/SRB2_release_$pkgver.tar.gz
	$pkgname-$pkgver-data.zip::https://github.com/STJr/SRB2/releases/download/SRB2_release_2.2.13/SRB2-v2213-Full.zip
	fix-backtrace.patch
	"
subpackages="$pkgname-data::noarch"
builddir="$srcdir/SRB2-SRB2_release_$pkgver"

build() {
	make -C src/ USE_OPENMP=1 EXENAME=srb2
	PROGRAM_NAME="Sonic Robo Blast 2" PROGRAM_DESCRIPTION="$pkgdesc" \
		PACKAGE_INSTALL_PATH="/usr/bin" PROGRAM_FILENAME="$pkgname" \
		envsubst < debian-template/srb2.desktop > srb2.desktop
}

package() {
	install -Dm755 bin/$pkgname $pkgdir/usr/bin/$pkgname
	install -Dm644 srb2.png $pkgdir/usr/share/pixmaps/srb2.png
	install -Dm644 srb2.desktop $pkgdir/usr/share/applications/srb2.desktop
}

data() {
	pkgdesc="$pkgdesc (data files)"

	cd "$srcdir/"
	install -d "$subpkgdir"/usr/share/games/SRB2
	install -m644 models.dat player.dta music.dta patch.pk3 srb2.pk3 zones.pk3 "$subpkgdir"/usr/share/games/SRB2
}

sha512sums="
b68dec859d2d08ec0ff8fc65a07ba5cdc80091a26bf06fadb3e7ae5e18489b6e4a9575d0d3b7fd626e6ccf0589a67e93a0df616df18df70524e5e3709979cf8a  srb2-2.2.13.tar.gz
0ede22cc385057f18715da445548c94473271d7ece49d3c540faab470232574bcaf9a2de32e2445c35bc3c98bcb0f06bcb891e4d953e4c1b003cd4a7e0599a5e  srb2-2.2.13-data.zip
2489a3c1e7abb2f8b66db00b13b809041c98757642844c1990d9d98c820efc8ca35a3498a5d0fad87086a31227118e3b883f49b948785f863ffd9e78e1ecb022  fix-backtrace.patch
"
